
let apiTypeData = [
    { name: "全部", keyword: "身份证实名", isnew: false },
    { name: "生活服务", keyword: "银行卡", isnew: false },
    { name: "金融科技", keyword: "短信", isnew: false },
    { name: "交通地理", keyword: "天气", isnew: false },
    { name: "充值缴费", keyword: "短信", isnew: false },
    { name: "数据智能", keyword: "手机归属地", isnew: false },
    { name: "企业工商", keyword: "IP", isnew: false },
    { name: "应用开发", keyword: "手机归属地", isnew: false },
    { name: "电子商务", keyword: "IP", isnew: false },
    { name: "吃喝玩乐", keyword: "视频", isnew: false },
    { name: "文娱视频", keyword: "视频", isnew: false },
    { name: "免费接口大全", keyword: "短信", isnew: true },
    { name: "短信", keyword: "身份证实名", isnew: false },
    { name: "汽车", keyword: "银行卡", isnew: false },
    { name: "核验", keyword: "银行卡", isnew: false },
    { name: "最新发布", keyword: "银行卡", isnew: true },
    { name: "API私有化部署", keyword: "身份证实名", isnew: true },
  ]
  let navhtml=''
    apiTypeData.forEach(function(v,i){
        
        navhtml+=`
        <a href="#" class="${i===0?'active1':''} ${v.isnew?'bold':''}"data-keyword=${v.keyword}>${v.name}</a>  
        `

    })

    $('.nav').innerHTML=navhtml


    $('.nav').addEventListener('click',function(e){
        
        if(e.target.nodeName==='A'){
               [...$('.nav').children].forEach(function(a){
                a.classList.remove('active1')
               })
            e.target.classList.add('active1')

            $('.search span').textContent=e.target.textContent

            $('.search-box input').placeholder=e.target.dataset.keyword
        }
    })


$a('.a4').forEach(function(v){
    v.addEventListener('click',function(){
        $('.mask').style.display='flex'
    })
})
$('.mask').addEventListener('click',function(){
    $('.mask').style.display='none'
})
$('.modal').addEventListener('click',function(e){
        e.stopPropagation()
})



// 手机号输入事件
$('#tel').addEventListener('input',function(){
   if(this.value){
    $('.img1').style.display='block'
   }else{
    $('.img1').style.display='none'
   }
})
// 点击按钮删除输入的账号
$('.img1').addEventListener('click',function(){
    $('#tel').value=''
    this.style.display='none'
})
// 密码输入事件
$('#password').addEventListener('input',function(){
    if(this.value){
     $('.img2').style.display='block'
    }else{
     $('.img2').style.display='none'
    }
 })
 // 点击按钮删除输入的密码
 $('.img2').addEventListener('click',function(){
    $('#password').value=''
    this.style.display='none'
})
// 验证手机号
let reg1=/^1[3|4|5|6|7|8|9][0-9]{9}$/
let reg2=/^[0-9]{6}$/
let num=0;
$('#btn').addEventListener('click',function(e){
   
    
    if(! reg1.test($('#tel').value)){
      let timer =setInterval(function(){
        $('.meng').style.display="block"
        $('.meng').textContent='用户名格式不正确'
            ++num
            if(num>2){
                $('.meng').style.display="none"
                $('.meng').textContent=''
                clearInterval(timer)
                num=0
            }

        },1000)
        e.preventDefault()

    }else if(!reg2.test($('#password').value)){
        let timer2=setInterval(function(){
            $('.meng').style.display="block"
            $('.meng').textContent='密码格式不正确'
            ++num
            if(num>2){
                $('.meng').style.display="none"
                $('.meng').textContent=''
                clearInterval(timer2)
                num=0
            }



        },1000)
        e.preventDefault()
    }





    
})



 
